package com.yc.demo.zy0301;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet(name = "XSServlet", value = "/XSServlet")
public class XSServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // 设置字符集
        request.setCharacterEncoding("utf-8");
        response.setCharacterEncoding("utf-8");
        response.setContentType("text/html;charset=utf-8");

        final PrintWriter out = response.getWriter();

        final HttpSession session = request.getSession();

        final String[] likes = (String[]) session.getAttribute("likes");

        out.printf("<h3>你的爱好</h3>");
        out.printf("<ol>");
        for (String s : likes){
            // response.getWriter().println(s);
            out.printf("<li> %s </li>", s);
        }
        out.printf("</ol>");
        out.printf("<br>");

        final String edu = (String) session.getAttribute("edu");
        // response.getWriter().println(edu);
        out.printf("<h3>你的学历</h3>");
        out.printf("<dd> %s </dd>", edu);
        out.printf("<br>");

        final String area = (String) session.getAttribute("area");
        // response.getWriter().println(area);
        out.printf("<h3>你的教育经历</h3>");
        out.printf("<dd> %s </dd>", area);
        out.printf("<br>");

    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
